FROM node:10-alpine as build

#这个似乎设了没意义，最终决定包来源的是yarn.lock，而它是在开发机上最后一次运行yarn得来的，也就是说真正的源其实由开发机决定
#RUN yarn config set registry 'http://192.168.1.31:4873' 
#RUN yarn config list

ARG TESTBUILD=0
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app/
COPY yarn.lock /app/
RUN yarn config list
RUN yarn
COPY src /app/src
COPY srcjs /app/srcjs
COPY gen /app/gen
COPY tsconfig.json /app/tsconfig.json
RUN yarn build
RUN if [ "$TESTBUILD" != "1" ]; then\
    rm -rf node_modules src &&\
    yarn --production --no-cache && yarn cache clean; \
    fi

FROM node:10-alpine
WORKDIR /app
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
COPY html /app/html
COPY swagger /app/swagger
COPY ssl /app/ssl
COPY package.json /app/package.json
CMD [ "yarn", "start" ]
